package org.r.items.tally.consumer.controller.test;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.apache.dubbo.config.annotation.DubboReference;
import org.r.items.tally.consumer.api.test.ConsumerTestRemote;
import org.r.items.tally.table.test.DemoUserTable;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Tag(name = "测试模块")
@RestController
@RequestMapping("/test")
public class SayHelloController {

    @DubboReference
    private ConsumerTestRemote consumerTestRemote;

    /**
     *  http://localhost:23080/test/hello
     * @return
     */
    @Operation(summary = "返回say hello",description = "我没什么要说明的")
    @GetMapping("/hello")
    public String hello(){
        return consumerTestRemote.sayHello();
    }


    /**
     *  http://localhost:23080/test/getUserById?id=888560001
     * @param id
     * @return
     */
    @Parameter(name = "id",description = "用户id",in = ParameterIn.QUERY)
    @Operation(summary = "根据id获取测试用户信息",description = "记住，传的参数是id哦")
    @GetMapping("/getUserById")
    public DemoUserTable getUserById(@RequestParam("id") Long id){
        return consumerTestRemote.getOneById(id);
    }

    /*
   @Operation(summary = "普通body请求+Param+Header+Path")
    @Parameters({
            @Parameter(name = "id",description = "文件id",in = ParameterIn.PATH),
            @Parameter(name = "token",description = "请求token",required = true,in = ParameterIn.HEADER),
            @Parameter(name = "name",description = "文件名称",required = true,in=ParameterIn.QUERY)
    })
    @PostMapping("/bodyParamHeaderPath/{id}")
    public ResponseEntity<FileResp> bodyParamHeaderPath(@PathVariable("id") String id,@RequestHeader("token") String token, @RequestParam("name")String name,@RequestBody FileResp fileResp){
        fileResp.setName(fileResp.getName()+",receiveName:"+name+",token:"+token+",pathID:"+id);
        return ResponseEntity.ok(fileResp);
    }


 */
}
